package com.hancher.gamelife2.function;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hancher.common.androidutil.LogUtil;
import com.hancher.common.javautil.GsonUtil;
import com.hancher.common.rv.BaseVBAdapter;
import com.hancher.gamelife2.R;
import com.hancher.gamelife2.databinding.ItemHome2Binding;

import lombok.Data;

public class Function2Adapter extends BaseVBAdapter<ItemHome2Binding, Function2Adapter.Function2Item> {
    @Override
    protected ItemHome2Binding createViewBinding(LayoutInflater from, ViewGroup viewGroup) {
        return ItemHome2Binding.inflate(from, viewGroup, false);
    }

    @Override
    protected void convertItem(ItemHome2Binding binding, int position, Function2Item item) {
        LogUtil.o("item : " + GsonUtil.obj2JsonStr(item));
        binding.itemName.setText(item.getTitle());
        if (item.getDrawable() < 0) {
            binding.image.setImageResource(R.drawable.icon_scan);
        } else {
            binding.image.setImageResource(item.getDrawable());
        }
        binding.itemClickMost.setVisibility(item.getClickSort() == 1 ? View.VISIBLE : View.GONE);
        binding.itemRecentMost.setVisibility(item.getRecentSort() == 1 ? View.VISIBLE : View.GONE);

    }

    @Data
    public static class Function2Item {
        private int drawable;
        private int action;
        private String title;
        private String tag;
        private int clickSort;
        private int recentSort;
        String md5;
    }
}
